# Maintainer: T.J. Townsend <blakkheim@archlinux.org>
# Contributor: Kyle Keen <keenerd@gmail.com>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Jaroslav Lichtblau <dragonlord@aur.archlinux.org>
# Contributor: Kessia 'even' Pinheiro <kessiapinheiro at gmail.com>
# Contributor: Sorin Ionescu <sorin.ionescu@gmail.com>

pkgname=ufw
pkgver=0.36.1
pkgrel=4
pkgdesc="Uncomplicated and easy to use CLI tool for managing a netfilter firewall"
arch=('any')
url="https://launchpad.net/ufw"
license=('GPL3')
depends=('iptables' 'python')
backup=('etc/ufw/before.rules'
        'etc/ufw/before6.rules'
        'etc/ufw/after.rules'
        'etc/ufw/after6.rules'
        'etc/ufw/ufw.conf'
        'etc/ufw/user.rules'
        'etc/ufw/sysctl.conf'
        'etc/default/ufw'
        'etc/ufw/user6.rules')
source=("https://launchpad.net/$pkgname/${pkgver%.*}/$pkgver/+download/$pkgname-$pkgver.tar.gz"
        "https://launchpad.net/$pkgname/${pkgver%.*}/$pkgver/+download/$pkgname-$pkgver.tar.gz.asc"
        service)
sha256sums=('1c57e78fbf2970f0cc9c56ea87a231e6d83d825e55b9e31e2c88b91b0ea03c8c'
            'SKIP'
            'fdface6f4690e4748fbbd5661c02e1967a8750fdb23581d35516174017a3fe39')
validpgpkeys=('4C20C06B5D8BDE688854D28A51DBDC58CC559573')

prepare() {
  cd "$pkgname-$pkgver"
  # FS#28769 - move from /lib to /usr/lib
  sed -i -e 's|/lib|/usr/lib|' \
         -e 's|sbin|bin|g' setup.py

  # FS#35458, FS#54110 - correct iptables location
  sed -i -e 's|sbin|bin|g' setup.py
  sed -i -e 's|sbin|bin|g' src/util.py
}

package() {
  cd "$pkgname-$pkgver"

  python3 setup.py install --root="$pkgdir"

  install -Dm644 shell-completion/bash "$pkgdir/usr/share/bash-completion/completions/ufw"
  install -Dm644 "$srcdir/service" "$pkgdir/usr/lib/systemd/system/ufw.service"
  chmod 644 "$pkgdir/etc/ufw/"*.rules
}
